{% extends "shop/base.html" %}
{% load i18n %}
{% load satchmo_currency satchmo_discounts %}

{% block navbar %}
   <li class="first"><a href="{{ shop_base }}/">{% trans "Home" %}</a></li>
{% endblock %}

{% block content %}

{% if not results.categories and not results.products %}
<h4>{% trans "Nothing found" %}</h4>
{% else %}
	{% if category %}{% with results.categories.0.translated_name as category_name %}
		<h4>{% blocktrans %}Search results for {{ category_name }} products{% endblocktrans %}</h4>
	{% endwith %}
	{% else %}
	 	{% if results.categories %}
			<h4>{% trans "Categories" %}</h4>
			<ul>
		    {% for category in results.categories %}
		        {% ifchanged %}<li><a href="{{ category.get_absolute_url }}">{{ category.translated_name }}</a></li>{% endifchanged %}
		    {% endfor %}
			</ul>
		{% endif %}
	{% endif %}
	{% if results.products %}
		{% if not category %}
		<h4>{% trans "Products" %}</h4>
		{% endif %}
		<ul>
		{% for product in results.products %}
	        {% ifchanged %}<li><a href="{{ product.get_absolute_url }}">{{ product.translated_name }}</a> {% trans "for" %} {{ product|discount_price:sale|currency}}</li>{% endifchanged %}
	    {% endfor %}
		</ul>
	{% else %}
		{% if category %}
			<p>{% trans "Nothing found" %}</p>
		{% endif %}
	{% endif %}
{% endif %}
{% endblock %}
